Creating a .reg File
You
can create registration files from scratch and then import them into
the Registry. This is a handy technique if you have some customizations
that you want to apply to multiple systems. To demonstrate the basic
structure of a registration file and its entries, Figure 5
shows two windows. The top window is the Registry Editor with a key
named Test highlighted. The Settings pane contains six sample settings:
the (Default) value and one each of the
five types of settings (binary, DWORD, expandable string, multistring,
and string). The bottom window shows the Test key in Notepad as an exported registration file (Test.reg).
Windows 7 registration files always start with the following header:
Windows Registry Editor Version 5.00
Tip
If you’re building a registration file for a Windows 9x, Me, or NT 4 system, change the header to the following:
Next
is an empty line followed by the full path of the Registry key that
will hold the settings you’re adding, surrounded by square brackets:
Below the key are the setting names and values, which use the following general form:
Tip
If you want to add a comment to a .reg file, start a new line and begin the line with a semicolon (;).
"SettingName"=identifier:SettingValue
SettingName | The name of the setting. Note that you use the @ symbol to represent the key’s Default value. |
identifier | A code that identifies the type of data. REG_SZ values don’t use an identifier, but the other four types do: |
| | dword | Use this identifier for a DWORD value. |
| | hex(b) | Use this identifier for a QWORD value. |
| | hex | Use this identifier for a binary value. |
| | hex(2) | Use this identifier for an expandable string value. |
| | hex(7) | Use this identifier for a multistring value. |
SettingValue | This is the value of the setting, which you enter as follows: |
| | String | Surround the value with quotation marks. |
| | DWORD | Enter an eight-digit DWORD value. |
| | QWORD | Enter
eight two-digit hexadecimal pairs, separated by commas, with the pairs
running from highest order to lowest. For example, to enter the QWORD
value 123456789abcd, you would use the following value: |
| | | cd,ab,89,67,45,23,01,00 |
| | Binary | Enter the binary value as a series of two-digit hexadecimal numbers, separating each number with a comma. |
| | Expandable string | Convert
each character to its hexadecimal equivalent and then enter the value
as a series of two-digit hexadecimal numbers, separating each number
with a comma, and separating each character with 00. |
| | Multistring | Convert
each character to its hexadecimal equivalent and then enter the value
as a series of two-digit hexadecimal numbers, separating each number
with a comma, and separating each character with 00, and separating
each string with space (00 hex). |
Tip
To delete a setting using a .reg file, set its value to a hyphen (-), as in this example:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Test]
"BinarySetting"=-
To delete a key, add a hyphen to the start of the key name, as in this example:
Windows Registry Editor Version 5.00
[-HKEY_CURRENT_USER\Test]
Renaming a Key or Setting
You won’t often need to rename existing keys or settings. Just in case, though, here are the steps to follow:
1. | In the Registry Editor, find the key or setting you want to work with, and then highlight it.
|
2. | Select Edit, Rename, or press F2.
|
3. | Edit the name and then press Enter.
|
Caution
Rename
only those keys or settings that you created yourself. If you rename
any other key or setting, Windows 7 might not work properly.
Creating a New Key or Setting
Many
Registry-based customizations don’t involve editing an existing setting
or key. Instead, you have to create a new setting or key. Here’s how
you do it:
1. | In the Registry Editor, select the key in which you want to create the new subkey or setting.
|
2. | Select Edit, New. (Alternatively, right-click an empty section of the Settings pane and then click New.) A submenu appears.
|
3. | If
you’re creating a new key, select the Key command. Otherwise, select
the command that corresponds to the type of setting you want: String
Value, Binary Value, DWORD Value, Multi-String Value, or Expandable
String Value.
|
4. | Type a name for the new key or setting.
|
5. | Press Enter.
|
Deleting a Key or Setting
Here are the steps to follow to delete a key or setting:
1. | In the Registry Editor, select the key or setting that you want to delete.
|
2. | Select Edit, Delete, or press Delete. The Registry Editor asks whether you’re sure.
|
3. | Click Yes.
|
Caution
Again,
to avoid problems, you should delete only those keys or settings that
you created yourself. If you’re not sure about deleting a setting, try
renaming it instead. If a problem arises, you can also return the
setting back to its original name.